package com.houweishi.module.record.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.record.domain.BizApprovalRecord;
import com.houweishi.module.record.service.IBizApprovalRecordService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 审批信息记录Controller
 * 
 * @author houweishi
 * @date 2023-02-21
 */
@RestController
@RequestMapping("/module/record")
public class BizApprovalRecordController extends BaseController
{
    @Autowired
    private IBizApprovalRecordService bizApprovalRecordService;

    /**
     * 查询审批信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizApprovalRecord bizApprovalRecord)
    {
        startPage();
        List<BizApprovalRecord> list = bizApprovalRecordService.selectBizApprovalRecordList(bizApprovalRecord);
        return getDataTable(list);
    }

    /**
     * 查询处理过的审批信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:record:list')")
    @GetMapping("/processed/list")
    public TableDataInfo processedList(BizApprovalRecord bizApprovalRecord)
    {
        startPage();
        List<BizApprovalRecord> list = bizApprovalRecordService.selectApprovalRecordProcessedList(bizApprovalRecord);
        return getDataTable(list);
    }

    /**
     * 导出审批信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:record:export')")
    @Log(title = "审批信息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizApprovalRecord bizApprovalRecord)
    {
        List<BizApprovalRecord> list = bizApprovalRecordService.selectBizApprovalRecordList(bizApprovalRecord);
        ExcelUtil<BizApprovalRecord> util = new ExcelUtil<BizApprovalRecord>(BizApprovalRecord.class);
        util.exportExcel(response, list, "审批信息记录数据");
    }

    /**
     * 获取审批信息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizApprovalRecordService.selectBizApprovalRecordById(id));
    }

    /**
     * 新增审批信息记录
     */
    @PreAuthorize("@ss.hasPermi('module:record:add')")
    @Log(title = "审批信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizApprovalRecord bizApprovalRecord)
    {
        return toAjax(bizApprovalRecordService.insertBizApprovalRecord(bizApprovalRecord));
    }

    /**
     * 修改审批信息记录
     */
    @PreAuthorize("@ss.hasPermi('module:record:edit')")
    @Log(title = "审批信息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizApprovalRecord bizApprovalRecord)
    {
        return bizApprovalRecordService.updateBizApprovalRecord(bizApprovalRecord);
    }

    /**
     * 删除审批信息记录
     */
    @PreAuthorize("@ss.hasPermi('module:record:remove')")
    @Log(title = "审批信息记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizApprovalRecordService.deleteBizApprovalRecordByIds(ids));
    }
}
